package cz.proks.schoolpupilbook.gae.dbo;

import java.util.Date;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.google.appengine.api.datastore.Key;

@Entity
public class MarkDBO implements IsIndexableDBO{
	private Key id;
	private Date time;
	private Key lectorKey;
	private Key courseKey;
	private Key studentKey;
	private String grade;	
	private List<MarkCommentDBO> comments;
		
	public MarkDBO() {	
	}
		
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Key getId() {
		return id;
	}
	public void setId(Key id) {
		this.id = id;
	}
	
	@Basic
	@Column(nullable=false)
	public Key getLectorKey() {
		return lectorKey;
	}

	public void setLectorKey(Key lectorKey) {
		this.lectorKey = lectorKey;
	}

	@Basic
	@Column(nullable=false)
	public Key getCourseKey() {
		return courseKey;
	}

	public void setCourseKey(Key courseKey) {
		this.courseKey = courseKey;
	}

	@Basic
	@Column(nullable=false)
	public Key getStudentKey() {
		return studentKey;
	}

	public void setStudentKey(Key studentKey) {
		this.studentKey = studentKey;
	}

	@Basic
	@Column(nullable=false)
	public String getGrade() {
		return grade;
	}
	public void setGrade(String grade) {
		this.grade = grade;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(nullable=false)
	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	@OneToMany(mappedBy="mark", fetch=FetchType.EAGER, cascade=CascadeType.ALL)
	public List<MarkCommentDBO> getComments() {
		return comments;
	}

	public void setComments(List<MarkCommentDBO> comments) {
		this.comments = comments;
	}		
}
